﻿using UnityEngine;
using System.Collections;

public class Portal : MonoBehaviour
{
	public GameObject endPortal;
	public Vector3 offset;
	public int reqPoints;
	
	GameObject player;
	
	// Use this for initialization
	void Start ()
	{
		player = GameObject.FindWithTag ("Player");
	}
	
	// Update is called once per frame
	void Update ()
	{
	}
	
	void OnTriggerStay (Collider other)
	{
		if (other.gameObject.name == "Player" && PlayerPrefs.GetInt("points") >= reqPoints) {
			player.transform.position = new Vector3 (endPortal.transform.position.x + offset.x, endPortal.transform.position.y + offset.y, endPortal.transform.position.z + offset.z);
		}
	}
}
